package ui.panel
{
	import flash.display.Bitmap;
	import flash.geom.Rectangle;

	import globals.Global;

	import manager.PopUpManager;

	import net.data.HeroInfo;

	import ui.component.ScaleBitmap;
	import ui.panel.common.HeroList;
	import ui.panel.trains.TrainDetail;
	import ui.panel.trains.TrainWarriorInfo;

	/**
	 * 训练面板
	 * @author luguobin
	 */
	public class TrainPanel extends BasePanel
	{
		private var _warriorTrainInfo:TrainWarriorInfo; //英雄信息。
		private var _trainDetail:TrainDetail; //训练详细内容。
		private var _heroList:HeroList;

		public function TrainPanel()
		{
			super();
			pid = PanelType.TRAIN_PANEL;
			updateTitle("训练");
		}

		override protected function initUI():void
		{
			super.initUI();
			//背景
			var contentBg:Bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("content_bg"));
			contentBg.x = 27;
			contentBg.y = 38;
			this.addChild(contentBg);
			////////右边///////////
			var rightBg:ScaleBitmap = new ScaleBitmap(Global.assetsManager.getAssetsAsBitmapData("tower_bg"));
			rightBg.scale9Grid = new Rectangle(35, 35, 14, 14);
			rightBg.width = 340;
			rightBg.height = 335;
			rightBg.x = 220;
			rightBg.y = 70;
			this.addChild(rightBg);
			//左边的
			_warriorTrainInfo = new TrainWarriorInfo();
			_warriorTrainInfo.x = 60;
			_warriorTrainInfo.y = 70;
			this.addChild(_warriorTrainInfo);

			_trainDetail = new TrainDetail();
			_trainDetail.x = 220;
			_trainDetail.y = 70;
			this.addChild(_trainDetail);

			_heroList = new HeroList();
			_heroList.selectCallback = selectHero;
			//TODO luguobin测试
			update();
		}

		private function selectHero(index:int):void
		{
			PopUpManager.removePopUp(_heroList);
		}

		public function update():void
		{
			_heroList.update(new Vector.<HeroInfo>());
		}

		public function popUpHeroList():void
		{
			_heroList.x = this.x + 200;
			_heroList.y = this.y + 65;
			PopUpManager.addPopUp(_heroList, true);
		}
	}
}